<template>
  <a-modal title='开票单位选择(可通过双击行选择)' :width='1000'  :dialog-style="{ top: '10px' }" :visible='visible' :confirmLoading='loading' :footer="null" @ok='handleSubmit' @cancel='close'>
    <f-search-form :more='false' @searchHandler='searchHandler'>
      <f-search-form-item label='单位名称' name='invoiceunitName' style='width: 350px'/>
    </f-search-form>
    <f-table ref='table' rowKey='invoiceUnitId' v-if='visible' :scroll='{y:300}' @dblclick='dblclick' :columns='columns' :multiple='false' :showRadio='true' :operator='operator' :params='queryParam' :api='api.invoiceunit' @onSelectChange='onSelectChange'>
    </f-table>
  </a-modal>
</template>
<script>
import api from "../js/api"

export default {
  name: "SelectInvoiceModal",
  props: {},
  data() {
    let operator = []
    return {
      refs: this.$refs,
      api: Object.assign(api, this.api),
      loading: false,
      visible: false,
      selectedRowKeys: [],
      selectedRows: [],
      //列表初始化查询参数
      queryParam: {},

      // 表头
      columns: [
        {
          title: "单位名称",
          align: "center",
          ellipsis: true,
          width: "180px",
          dataIndex: "invoiceunitName"
        },
        {
          title: "开户行",
          align: "center",
          width: "180px",
          ellipsis: true,
          dataIndex: "bankName"
        },
        {
          title: "开户号",
          align: "center",
          width: "130px",
          dataIndex: "bankNo"
        },
        {
          title: "税率",
          align: "center",
          width: "80px",
          dataIndex: "taxNo"
        }
      ],
      operator: operator
    }
  },
  methods: {
    open(params) {
      this.queryParam = params
      this.visible = true
      this.selectedRowKeys = []
      this.selectedRows = []
    },
    close() {
      this.$emit("close")
      this.visible = false
    },
    dblclick(record, event) {
      let selectedRowKeys = []
      let selectedRows = []
      selectedRowKeys.push(record.invoiceUnitId)
      selectedRows.push(record)
      this.$emit("onSelectChange", selectedRowKeys, selectedRows)
      this.close()
    },
    handleSubmit() {
      this.$emit("onSelectChange", this.selectedRowKeys, this.selectedRows)
      this.close()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    }
  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
